namespace JGSY.CMS.LowCode.Platform.Domain.Entities.Base;

/// <summary>
/// 实体基类
/// 提供统一的主键和审计字段
/// </summary>
public abstract class BaseEntity
{
    /// <summary>
    /// 主键ID - 统一使用long类型
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

/// <summary>
/// 可审计实体基类
/// </summary>
public abstract class AuditableEntity : BaseEntity
{
    /// <summary>
    /// 创建人ID
    /// </summary>
    public long? CreatedBy { get; set; }

    /// <summary>
    /// 更新人ID
    /// </summary>
    public long? UpdatedBy { get; set; }

    /// <summary>
    /// 软删除标记
    /// </summary>
    public bool IsDeleted { get; set; } = false;

    /// <summary>
    /// 删除时间
    /// </summary>
    public DateTime? DeletedAt { get; set; }

    /// <summary>
    /// 删除人ID
    /// </summary>
    public long? DeletedBy { get; set; }
}

/// <summary>
/// 可排序实体基类
/// </summary>
public abstract class SortableEntity : AuditableEntity
{
    /// <summary>
    /// 排序序号
    /// </summary>
    public int SortOrder { get; set; } = 0;
}

/// <summary>
/// 可发布实体基类
/// </summary>
public abstract class PublishableEntity : AuditableEntity
{
    /// <summary>
    /// 是否已发布
    /// </summary>
    public bool IsPublished { get; set; } = false;

    /// <summary>
    /// 发布时间
    /// </summary>
    public DateTime? PublishedAt { get; set; }

    /// <summary>
    /// 发布人ID
    /// </summary>
    public long? PublishedBy { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public string Status { get; set; } = "Draft";
}

/// <summary>
/// 树形结构实体基类
/// </summary>
public abstract class HierarchicalEntity : SortableEntity
{
    /// <summary>
    /// 父级ID
    /// </summary>
    public long? ParentId { get; set; }

    /// <summary>
    /// 层级路径 (如: /1/2/3)
    /// </summary>
    public string Path { get; set; } = string.Empty;

    /// <summary>
    /// 层级深度
    /// </summary>
    public int Level { get; set; } = 0;
}
